﻿@model TaxTypeSelectorModel
@inject IWebHelper webHelper
@{
    var returnUrl = webHelper.GetRawUrl(Context.Request);
    var taxTypes = new List<SelectListItem>();
    taxTypes.Add(new SelectListItem
    {
        Text = T("Tax.Inclusive").Text,
        Value = Url.RouteUrl("ChangeTaxType", new { customertaxtype = ((int)TaxDisplayType.IncludingTax), returnUrl }),
        Selected = Model.CurrentTaxType == TaxDisplayType.IncludingTax
    });
    taxTypes.Add(new SelectListItem
    {
        Text = T("Tax.Exclusive").Text,
        Value = Url.RouteUrl("ChangeTaxType", new { customertaxtype = ((int)TaxDisplayType.ExcludingTax), returnUrl }),
        Selected = Model.CurrentTaxType == TaxDisplayType.ExcludingTax
    });
}
<div class="btn-group btn-group-sm float-xs-right pr-1 d-flex tax-type-button">
    <button type="button" class="btn dropdown-toggle" data-toggle="dropdown">
        <span>@taxTypes.FirstOrDefault(x => x.Selected).Text</span>
        <span class="sr-only">Toggle Dropdown</span>
        <span class="mdi mdi-chevron-down"></span>
    </button>
    <div class="dropdown-menu tax">
        <ul class="pl-0 mb-0">
            @foreach (var item in taxTypes)
            {
                var className = item.Selected ? "active" : "";
                <li class="@className">
                    <a class="text-dark" href="@item.Value">@item.Text</a>
                </li>
            }
        </ul>
    </div>
</div>